00001 // 00002 // Copyright (c) 2013 Battelle Memorial Institute 00003 // Licensed under modified BSD License. A copy of this license can be found 00004 // in the LICENSE file in the top level directory of this distribution. 00005 // 00006 // Emacs Mode Line: -*- Mode:c++;-*- 00007 // ------------------------------------------------------------- 00008 /** 00009 * @file indexed.h 00010 * @author William A. Perkins 00011 * @date Mon Mar 25 10:48:31 2013 00012 * 00013 * @brief 00014 * 00015 * 00016 */ 00017 // ------------------------------------------------------------- 00018 // ------------------------------------------------------------- 00019 // Created March 25, 2013 by William A. Perkins 00020 // Last Change: Thu Jun 3 06:45:08 2010 by William A. Perkins <d3g096@PE10900.pnl.gov> 00021 // ------------------------------------------------------------- 00022 00023 #ifndef _indexed_h_ 00024 #define _indexed_h_ 00025 00026 namespace gridpack { 00027 namespace utility { 00028 00029 // ------------------------------------------------------------- 00030 // class Indexed 00031 // ------------------------------------------------------------- 00032 class Indexed { 00033 public: 00034 00035 /// The index type 00036 /** 00037 * To add some flexibility. This may need to be a 64-bit integer or 00038 * unsigned or whatever. 00039 * 00040 */ 00041 typedef int IndexType; 00042 00043 /// Default constructor. 00044 Indexed(void) 00045 : local_index_(bogus_index_), global_index_(bogus_index_) 00046 {} 00047 00048 /// Protected copy constructor to avoid unwanted copies. 00049 Indexed(const Indexed& old) 00050 : local_index_(old.local_index_), 00051 global_index_(old.global_index_) 00052 {} 00053 00054 /// Destructor 00055 virtual ~Indexed(void) {}; 00056 00057 /// Get the local index of this instance 00058 IndexType get_local_index(void) const 00059 { 00060 return local_index_; 00061 } 00062 00063 /// Get the local index of this instance 00064 void set_local_index(const IndexType& l) 00065 { 00066 local_index_ = l; 00067 } 00068 00069 /// Get the global index of this instance 00070 IndexType get_global_index(void) const 00071 { 00072 return global_index_; 00073 } 00074 00075 /// Set the global index of this instance 00076 void set_global_index(const IndexType& g) 00077 { 00078 global_index_ = g; 00079 } 00080 00081 protected: 00082 00083 static const bogus_index_; 00084 IndexType local_index_; 00085 IndexType global_index_; 00086 00087 }; 00088 00089 } // namespace utility 00090 } // namespace gridpack 00091 00092 00093 #endif